import { Meta, StoryObj } from "@storybook/react/*";
import Calendar, { CalendarProps } from "../components/Calendar3";
import dayjs from "dayjs";

const meta = {
    title: '日历组件',
    component: Calendar,
    parameters: {
        layout: 'center'
    },
    argTypes: {
        value: {
            control: 'date'
        }
    },
    tags: ['autodocs']
} satisfies Meta<typeof Calendar>

export default meta

const renderCalendar = (args: CalendarProps) => {
    if(typeof args.value === 'number') {
        return <Calendar {...args} value={dayjs(new Date(args.value))}/>
    }

    return <Calendar {...args}/>
}

type Story = StoryObj<typeof meta>

export const Value:Story = {
    args: {
        value: dayjs('2023-11-05'),
        // dateRender(currentDate) {
        //     return <div>
        //         日期{currentDate.date()}
        //     </div>
        // }
    },
    render: renderCalendar
}

export const DateRender: Story = {
    args: {
        value: dayjs('2023-11-09'),
        dateInnerContent(currentDate) {
            return <div>
                日期{currentDate.date()}
            </div>
        }
    },
    render: renderCalendar
}

export const Local: Story = {
    args: {
        value: dayjs('2023-11-10'),
        locale: 'en-US'
    },
    render: renderCalendar
}